﻿using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;

namespace NewFormatProject.Repository.Interfaces
{
    public interface IRepository<T> where T : class, new()
    {
        DbSet<T> TSet();
        IQueryable<T> Query();
        IQueryable<T> Query(Expression<Func<T, bool>> where);
        IQueryable<T> Query<TKey>(Expression<Func<T, bool>> where, bool isAsc, Expression<Func<T, TKey>> order);
        IQueryable<T> Pagination1<TKey>(Expression<Func<T, bool>> where, bool isAsc, Expression<Func<T, TKey>> order,out int total, int page, int limit);
        IQueryable<T> Pagination2<TKey>(IQueryable<T> iq,Expression<Func<T, bool>> where, bool isAsc, Expression<Func<T, TKey>> order, out int total, int page, int limit);
        Task<int> Add(T t);
        Task<int> Add(IEnumerable<T> ie);
        Task<int> UpdateAllProper(T t);
        Task<int> UpdateAllProper(IEnumerable<T> t);
        Task<int> UpdateAllProperNotNull(T t);
        Task<int> UpdateAllProperNotNull(IEnumerable<T> ie);
        Task<int> Delete(T t);
        Task<int> Delete(IEnumerable<T> ie);
        Task<int> Save();
        Task<int> Transaction(Func<Task<int>> operation1, Func<Task<int>> operation2);
    }
}
